var a = require("../../../@babel/runtime/helpers/interopRequireDefault"), t = a(require("../../../@babel/runtime/regenerator")), e = require("../../../@babel/runtime/helpers/asyncToGenerator"), i = a(require("../dateParserTime")), o = getApp();

Page({
    data: {
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        msg_body: {
            title: "直播间标题",
            img: "直播间封面图"
        }
    },
    onLoad: function(a) {
        this.getListData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    gotoPages: function(a) {
        var t = a.currentTarget.dataset.page;
        "" != t && null != t && wx.navigateTo({
            url: t
        });
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    initData: function() {
        this.data.page = 1, this.data.isLoadMore = !0, this.data.total_page = 0;
    },
    getListData: function() {
        var a = this;
        return e(t.default.mark(function e() {
            var s;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    a.initData(), s = o.getNetAddresss("plugin.instation-message.api.message.get-type-list"), 
                    o._postNetWork({
                        url: s,
                        data: {
                            type_id: 6
                        },
                        success: function(t) {
                            var e = t.data;
                            if (1 !== e.result) return a.tips(e.msg);
                            e.data.data.forEach(function(a) {
                                a.created_at = (0, i.default)(a.created_at);
                            }), a.data.isLoadMore = !0, a.data.total_page = e.data.last_page, a.data.total_page || (a.data.total_page = 0), 
                            a.setData({
                                listData: e.data.data
                            });
                        }
                    });

                  case 3:
                  case "end":
                    return t.stop();
                }
            }, e);
        }))();
    },
    _getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var t = o.getNetAddresss("plugin.instation-message.api.message.get-type-list");
            o._postNetWork({
                url: t,
                data: {
                    type_id: 6,
                    page: this.data.page
                },
                success: function(t) {
                    var e = t.data;
                    if (a.data.isLoadMore = !0, 1 === e.result) {
                        var o = e.data.data;
                        o.forEach(function(a) {
                            a.created_at = (0, i.default)(a.created_at);
                        });
                        var s = a.data.listData.concat(o);
                        a.setData({
                            listData: s
                        });
                    } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1;
                }
            });
        }
    },
    tips: function(a) {
        return wx.showToast({
            title: a,
            icon: "none",
            duration: 2e3
        }), !1;
    }
});